package com.aipsi.cws.auto.pages.tab5.supplier;

import com.appium.manager.element.anno.PageElement;
import lombok.extern.slf4j.Slf4j;
import com.aipsi.cws.auto.common.BasePage;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import java.util.List;


@Slf4j
public class SupplierDetailPage extends BasePage {

	@FindBy(name = "supplierName")
	private List<WebElement> supplierName;

	@FindBy(name = "legalPerson")
	private List<WebElement> legalPerson;

	@FindBy(name = "mobileNumber")
	private List<WebElement> mobileNumber;

	@FindBy(name = "phoneNumber")
	private List<WebElement> phoneNumber;

	@FindBy(name = "address")
	private List<WebElement> address;

	@FindBy(name = "debt")
	private List<WebElement> debt;

	@FindBy(name = "bocAccount")
	private List<WebElement> bocAccount;

	@FindBy(name = "abcAccount")
	private List<WebElement> abcAccount;

	@FindBy(name = "icbcAccount")
	private List<WebElement> icbcAccount;

	@FindBy(name = "ccbAccount")
	private List<WebElement> ccbAccount;

	@FindBy(name = "bocomAccount")
	private List<WebElement> bocomAccount;

	@FindBy(css = "body > app-root > ion-app > ion-router-outlet > app-tabs > ion-tabs > div > ion-router-outlet > app-supplier-detail > ion-header > ion-toolbar > ion-buttons.buttons-first-slot.sc-ion-buttons-md-h.sc-ion-buttons-md-s.md.hydrated > ion-back-button")
	private WebElement backButton;

	@FindBy(css = "body > app-root > ion-app > ion-router-outlet > app-tabs > ion-tabs > div > ion-router-outlet > app-supplier-detail > ion-header > ion-toolbar > ion-buttons:nth-child(4) > ion-button")
	private WebElement editButton;

	@FindBy(css = "body > app-root > ion-app > ion-router-outlet > app-tabs > ion-tabs > div > ion-router-outlet > app-supplier-detail > ion-header > ion-toolbar > ion-buttons.buttons-last-slot.sc-ion-buttons-md-h.sc-ion-buttons-md-s.md.hydrated > ion-button")
	private WebElement saveButton;

	public SupplierDetailPage(PageElement pageElement, Class<?> curTestClass) {
		super(pageElement, curTestClass);
	}

	public SupplierDetailPage choseFirst() throws InterruptedException {
		clickByCoordinate(450,490);
		waitWhile();
		return this;
	}

	public SupplierDetailPage clickSaveButton(){
		saveButton.click();
		log.info("点击保存供应商按钮");
		return this;
	}


	public SupplierDetailPage clickEditButton(){
		editButton.click();
		log.info("点击修改供应商页面的按钮");
		return this;
	}

	public SupplierDetailPage clickBackButton(){
		backButton.click();
		log.info("点击修改供应商页面的回退按钮");
		return this;
	}
}
